<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OAUTH2 回 调</title>
</head>
<body>
    <div>
        <h2 style="text-align: center">OAUTH2 回 调</h2>
    </div>
</body>
<script>
    function param2Obj(url) {
        const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
        if (!search) {
            return {}
        }
        const obj = {}
        const searchArr = search.split('&')
        searchArr.forEach(v => {
            const index = v.indexOf('=')
            if (index !== -1) {
            const name = v.substring(0, index)
            const val = v.substring(index + 1, v.length)
            obj[name] = val
            }
        })
        return obj
    }

    function a() {
        var code = param2Obj(window.location.href)['code']
        if (code) {
            if (window.localStorage) {
                window.localStorage.setItem('x-admin-oauth2-code', code)
                window.localStorage.clear('x-admin-oauth2-code')
            }
        } 
        window.close()
    }
    a()
</script>
</html>